package cn.wolfcode.trip.app.web.controller;

import cn.wolfcode.trip.base.domain.Gameintel;
import cn.wolfcode.trip.base.service.IGameIntelService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/game")
public class GameIntelController {

    @Autowired
    private IGameIntelService service;


    //游戏分数的处理
    @PostMapping("/insert")
    @ResponseBody
    public Object saveTravelComment(Gameintel g) {
        //保存完返回这个
        service.saveScore(g);
        JSONResult result = new JSONResult();
        return result;
    }


    /**
     * 查询一个用户现在拥有的积分,直接加入到积分中去
     *
     * @param userId
     * @return
     */
    @GetMapping("/get")
    @ResponseBody
    public Object getScore(Long userId) {
        Gameintel gameintel = service.get(userId);
        if (gameintel == null) {
            gameintel = new Gameintel();
        }
        return gameintel;
    }


}
